package cn.com.agameofthrones.AGoTLCGCards;

import java.util.Iterator;
import java.util.Set;

public class StringUtils {
	
	/**
	 * Join. Create regular expression from the set. Example:
	 * if set is "(hs),(hm),(ht)" and div is "|", the return value is
	 * "(hs)|(hm)|(ht)"
	 * @param set the set
	 * @param div the div
	 * @return the string
	 */
	public static String join(Set<String> set, String div){
		String result="";
		Iterator<String> itr=set.iterator();
		while(itr.hasNext()){
			result+=itr.next()+div;
		}
		if(result.length()>0){
			result=result.substring(0, result.length()-1); //remove the last 'div' for last element;
		}
		return result;
	}

}
